/**
 * @author root
 */
//TODO: make a element can accept drop
Package("j2j.effect.dnd").Class("Dropable", {
    Dropable: function(config){
    
    },
    Prototype: {
        extendController: function(config){
            var egr = Import("j2j.event.EventMgr");
            var g = Import("j2j.dom.Geometry");
            var Dispatcher = Import("j2j.effect.dnd.Dispatcher").getInstance();
            var type = config.type;
            var _this = this;
            var dom = this.dom;
            this.onDrop = config.onDrop ||
            function(){
            };
            var onDropHandler = function(e){
                var self = egr.getTarget(e);
                _this.dispatchEvent({
                    type: "drop",
                    self: self,
                    e: e
                });
                /*if (config.ondrop) 
                 config.ondrop(self, e);*/
                egr.stopEvent(e);
            };
            egr.addEventListener(dom, "dragstart", onDropHandler, false);
            Dispatcher.registerInterest(dom, type);
            
            this.finalize = function(obj){
                egr.removeEventListener(dom, "dragstart", onDropHandler, false);
                this.Super.finalize(this);
            };
        }
    },
    Extends: j2j.patterns.Decorator
});
